home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.700 < prev    next >
Text File  |  1992-02-06  |  3KB  |  89 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\fmodern Courier;}
  2. \paperw11040
  3. \paperh6300
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 FrameBuffer Depth\
  8. \
  9.  
  10. \fi-420\li420 Q:  How can my program tell whether it is running on a system with a color screen?  How can I tell whether I'm running on the 12-bit NextStation Color or the 24-bit NextDimension?\
  11.  
  12. \fi0\li0 \
  13.  
  14. \fi-440\li440 A:  The PostScript graphics model allows you to do all your rendering in 24-bit color,  and have the window server display it in the best way possible (dithering it down to 2-bits,  if necessary).  If there are situations in which you need to use the "inquire and adapt" approach, the Appkit provides you with a method in the Application class called 
  15. \b colorScreen
  16. \b0  that returns the most colorful screen available to your application.  By examining this data structure,  you can determine how deep your color screen is.  Below is a code fragment that does this:\
  17.  
  18. \fi0\li0 \
  19.  
  20. \pard\tx1240\tx2480\tx3740\tx4980\tx6240\tx7480\tx8720\tx9980\tx11220\tx12480\fc0 #import <appkit/Application.h>\
  21. #import <appkit/screens.h>\
  22. ...\
  23. \{\
  24.     const NXScreen *deepestScreen;\
  25.     \
  26.     deepestScreen=[NXApp colorScreen];\
  27.     \
  28.     switch ( deepestScreen->depth ) \{\
  29.     \
  30.         case NX_TwelveBitRGBDepth :\
  31.             /* Twelve Bit Color */\
  32.             break;\
  33.             \
  34.         case NX_TwentyFourBitRGBDepth :\
  35.             /* True Color */\
  36.             break;\
  37.             \
  38.         case NX_TwoBitGrayDepth :\
  39.         default :\
  40.             /* Greyscale */\
  41.             break;\
  42.             \
  43.         \}\
  44. \}    \
  45.  
  46. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  47. \
  48.  
  49. \fi-340\li340 Q: How can I tell whether a View can display color or not?\
  50.  
  51. \fi0\li0 \
  52.  
  53. \fi-380\li380 A: The above question does not answer which kinds of rendering commands you should be sending for a given View.  There are two headed systems,  and other circumstances where the window you are drawing in is not based on the value of 
  54. \b colorScreen
  55. \b0 . The most common thing you want to do is different rendering based on whether this View can display color or not.  One way to do this is to use the 
  56. \b shouldDrawColor
  57. \b0  method of View.  Do the following in your drawSelf:: method for the View:\
  58. \
  59.  
  60. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0     - drawSelf:(NXRect *)rects :(int)count\
  61.     \{\
  62.          if ([self shouldDrawColor]) \{\
  63.         ... color-specific drawing ...\
  64.           \} else \{\
  65.                  ...\
  66.             \}\
  67.             ...\
  68.     \}\
  69.  
  70. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fi-380\li380 \
  71.  
  72. \fi-20 If you need to know  the actual depth of a given window,  use the  
  73. \b depthLimit
  74. \b0  method of Window. Here's some code for that:\
  75.  
  76. \fi0\li0 \
  77.  
  78. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0     NXWindowDepthLimit     depth;\
  79.     if ((depth = [myWindow depthLimit]) == NX_DefaultDepth) \{\
  80.         depth = [Window defaultDepthLimit];\
  81.     \}\
  82.  
  83. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  84. QA700\
  85. \
  86. Valid for 2.0 only\
  87. \
  88.  
  89.